Add option to disable GET request cache #3
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Back-port from Apollo Server 3 repo: apollographql/apollo-server#6650
Fixes apollographql/apollo-server#6603
By default,
RESTDataSource
caches all outgoing GET requests in a separate memoized cache from the regular response cache. It makes the assumption that all responses from HTTP GET calls are cacheable by their URL.If a request is made with the same cache key (URL by default) but with an HTTP method other than GET, the cached request is then cleared.
This change adds a new class property
requestCacheEnabled
(which defaults totrue
to match current behavior) which allows users to disable the cache. You might want to do this if your API is not actually cacheable or your data changes over time.Separately it documents this feature exists and adds more info about how to set a TTL for the entire HTTP cache